Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve missing nodetoolkit #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

scroix
Copy link

@scroix scroix commented Dec 8, 2022

As mentioned in the public PR (museumsvictoria#250 (comment)) the nodetoolkit which provides all the action/event and utility functions wasn't available in the Jython interpreter.

It seems this was because the toolkit itself node_root/.nodel/nodetoolkit.py was missing from sys.path. There was an attempt to add it to the pySystemState but for some reason this was commented out in the original code.

I also took the opportunity to update this endeavour to Jython 2.7.3 which came out recently.

@@ -568,7 +560,6 @@ private void applyConfig0(NodeConfig config) throws Exception {

trackFunction("(instance creation)");

// _python = new PythonInterpreter(globals, pySystemState);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's strange this object gets built up with the correct working directories but never passed to the interpreter.

@scroix
Copy link
Author

scroix commented Dec 8, 2022

You can achieve the same result from within the Jython interpreter by doing this after the node launches.

import sys
sys.path.append(_node.getRoot().getAbsolutePath())
sys.path.append(str(_node.getRoot().getAbsolutePath()) + '\\.nodel')
from nodetoolkit import *

If you wanted to do it from Java whilst instantiating the interpreter object, just before the script launches, this works as well.

_python.exec("import sys");
_python.exec("sys.path.append(_node.getRoot().getAbsolutePath())");
_python.exec("sys.path.append(str(_node.getRoot().getAbsolutePath()) + '\\.nodel')");
_python.exec("from nodetoolkit import *");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants